﻿#if UNITY_4_1

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

[CustomEditor(typeof(UIManager))]
public class UIManagerInspector : Editor
{
	UIManager manager;
	
	void OnEnable()
	{
		manager = target as UIManager;
	}
	
	static bool showAtlas = false;
	static bool showFont = false;
	static bool showMaterial = false;
	static bool showEffect = false;
	static bool showSounds = false;
	public override void OnInspectorGUI ()
	{
		manager.forcePerfectPixel = EditorGUILayout.Toggle("ForcePerfectPixel", manager.forcePerfectPixel);
		
		showAtlas = EditorGUILayout.Toggle("ShowAtlas", showAtlas);
		if(showAtlas)
		{
			foreach(string key in UIManager.atlasList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.atlasList[key].atlas, typeof(UIAtlas), false);
			}
		}
		
		showFont = EditorGUILayout.Toggle("ShowFont", showFont);
		if(showFont)
		{
			foreach(string key in UIManager.fontList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.fontList[key].font, typeof(UIFont), false);
			}
		}
		
		showMaterial = EditorGUILayout.Toggle("ShowMaterial", showMaterial);
		if(showMaterial)
		{
			foreach(string key in UIManager.materialList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.materialList[key].material, typeof(Material), false);
			}
		}
		
		showEffect = EditorGUILayout.Toggle("ShowEffect", showEffect);
		if(showEffect)
		{
			foreach(string key in UIManager.effectList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.effectList[key].obj, typeof(GameObject), false);
			}
		}
		
		showSounds = EditorGUILayout.Toggle("ShowSounds", showSounds);
		if(showSounds)
		{
			foreach(string key in UIManager.soundsList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.soundsList[key].audioClip, typeof(AudioClip), false);
			}
		}
	}
}

#else

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;

[CustomEditor(typeof(UIManager))]
public class UIManagerInspector : Editor
{
	UIManager manager;
	
	void OnEnable()
	{
		manager = target as UIManager;
	}
	
	static bool showAtlas = false;
	static bool showFont = false;
	static bool showMaterial = false;
	static bool showEffect = false;
	static bool showSounds = false;
	public override void OnInspectorGUI ()
	{
		manager.forcePerfectPixel = EditorGUILayout.Toggle("ForcePerfectPixel", manager.forcePerfectPixel);
		
		showAtlas = EditorGUILayout.Toggle("ShowAtlas", showAtlas);
		if(showAtlas)
		{
			foreach(string key in UIManager.atlasList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.atlasList[key], typeof(UIAtlas), false);
			}
		}
		
		showFont = EditorGUILayout.Toggle("ShowFont", showFont);
		if(showFont)
		{
			foreach(string key in UIManager.fontList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.fontList[key], typeof(UIFont), false);
			}
		}
		
		showMaterial = EditorGUILayout.Toggle("ShowMaterial", showMaterial);
		if(showMaterial)
		{
			foreach(string key in UIManager.materialList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.materialList[key], typeof(Material), false);
			}
		}
		
		showEffect = EditorGUILayout.Toggle("ShowEffect", showEffect);
		if(showEffect)
		{
			foreach(string key in UIManager.effectList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.effectList[key], typeof(GameObject), false);
			}
		}
		
		showSounds = EditorGUILayout.Toggle("ShowSounds", showSounds);
		if(showSounds)
		{
			foreach(string key in UIManager.soundsList.Keys)
			{
				EditorGUILayout.ObjectField(key, UIManager.soundsList[key], typeof(AudioClip), false);
			}
		}
	}
}

#endif